home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / science / mcalc13.zip / CALC.CED next >
Text File  |  1994-02-15  |  2KB  |  82 lines

  1. /************************************************************************
  2.  *
  3.  * Calc.ced                              by Kai Iske
  4.  *
  5.  * Takes the expression enclosed by quotes and replaces
  6.  * it with the result (normal output)
  7.  *
  8.  *
  9.  * LoopUp part taken from (and modified a bit) :
  10.  *
  11.  * LookUp.ced       Copyright (c) 1989, Peter Cherna
  12.  *
  13.  * ARexx program for CygnusEd Professional that looks up the word under
  14.  * the cursor.
  15.  *
  16.  * Version 1.30:  August 20, 1989    Release 1.2:  August 29, 1989
  17.  *
  18.  ************************************************************************/
  19.  
  20.  
  21. OPTIONS RESULTS
  22. ADDRESS 'rexx_ced'
  23.  
  24.  
  25. tabchar = '09'X
  26. cr    = '0A'X
  27.  
  28. /*    Get contents of current line: */
  29. status 55
  30. line = result
  31.  
  32. /*    Get tab size: */
  33. status 8
  34. tabadjust = result - 1
  35.  
  36. /*    Get cursor x position (relative to beginning of line = 1): */
  37. status 46
  38. cur = result + 1
  39.  
  40. status 47
  41. currentline = result + 1
  42.  
  43. i = index(line,tabchar)
  44. DO while i > 0 & i <= cur - tabadjust
  45.     cur = cur - tabadjust
  46.     i = index(line,tabchar,i+1)
  47. END
  48.  
  49. /*    Find leftmost and rightmost alphabetic character adjacent to current: */
  50.  
  51. left = cur + 1
  52. char = ' '
  53. DO while (char ~= '"') & (left > 0)
  54.      left = left - 1
  55.     if left > 0 then
  56.         char = substr(line,left,1)
  57. END
  58.  
  59. right = left + 1
  60. char = ' '
  61. DO while (char ~= '"') & (right <= length(line))
  62.     right = right + 1
  63.     char = substr(line,right,1)
  64. END
  65.  
  66. if right-left < 1 then
  67.     exit
  68. else
  69.     target = substr(line,left+1,right-left-1)
  70.  
  71.  
  72.  
  73. JUMPTO currentline left
  74. MARK BLOCK
  75. JUMPTO currentline right + 1
  76. CUT BLOCK
  77.  
  78. ADDRESS 'MCALC' CALC target
  79. TEXT result
  80.  
  81. exit
  82.